package com.example.springbootdemo.utils;


import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * @ClassName: BetweenDate
 * @Description:
 * @Author: TXW
 * @Date: 2023-08-15
 */

public class BetweenDate {


    public static void main(String[] args) {
        LocalDate startDate = new LocalDate(2023, 1, 1);
        LocalDate endDate = new LocalDate(2023, 8, 31);
        DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");

        while (!startDate.isAfter(endDate)) {
            String formattedDate = startDate.toString(formatter);
            System.out.println(formattedDate.split("-")[0]);
            System.out.println(Integer.parseInt(formattedDate.split("-")[1]));
            startDate = startDate.plusMonths(1); // Move to the next day
        }
    }
}
